package org.csc.sss.datacore.security;

import org.csc.sss.datacore.primary.repository.SysUserRepository;
import org.csc.sss.datacore.primary.repository.impl.SysUserRepositoryImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class MyUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {

    @Autowired
    private SysUserRepository sysUserRepository;
    @Autowired
    private SysUserRepositoryImpl sysUserRepositoryImpl;

    @Override
    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {


        String username = super.obtainUsername(request);
        log.info("登录之前的拦截username========{}", username);

        return super.attemptAuthentication(request, response);
    }
}
